// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import Mint from 'mint-ui'  //mint-ui
import 'mint-ui/lib/style.css'  //mint-ui
import 'lib-flexible/flexible' //px--->rem
import ElementUI from 'element-ui'; //element-ui
import 'element-ui/lib/theme-chalk/index.css';//element-ui
import store from './assets/store/store.js' //全局中引入vuex
import { Toast } from 'mint-ui';
import qs from 'qs';

Vue.use(Mint);
Vue.use(ElementUI);
Vue.config.productionTip = false

import { Button, Select } from 'element-ui';
Vue.component(Button.name, Button);

//POST传参序列化
axios.interceptors.request.use((config) => {
  if(config.method  === 'post' && myVue.$store.state.isfile != true){
    ///////////加了{ arrayFormat: 'brackets' }
    config.data = qs.stringify(config.data,{arrayFormat:'brackets'});
    myVue.$store.state.isfile = false;
  }
  
  return config;
},(error) =>{
  return Promise.reject(error);
});
// `timeout`指定请求超时之前的毫秒数。 如果请求的时间超过'timeout'，请求将被中止。
axios.defaults.timeout = 5000;
// `withCredentials`指示是否跨站点访问控制请求
// axios.defaults.withCredentials=true;
//全局配置axios的请求文件类型
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
Vue.prototype.$http = axios
Vue.http = axios

var myVue = new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
